package io.chenglicun.common.trans.core;

import io.chenglicun.common.trans.annotation.Trans;
import lombok.Getter;
import org.apache.commons.lang3.StringUtils;

import java.lang.reflect.Field;

@Getter
public class TransField {

    /**
     * 需要被翻译的属性名称
     */
    private final String trans;

    /**
     * 需要翻译的属性
     */
    private final Field field;

    private final String key;

    public TransField(Trans trans, Field field) {
        this.trans = trans.trans();
        this.field = field;
        String k = trans.key();
        if (StringUtils.isBlank(k)) {
            k = field.getName();
        }
        this.key = k;
    }


}
